package com.atguigu.gulimall.search.controller;

import com.atguigu.common.utils.R;
import com.atguigu.gulimall.search.es.SkuEsModel;
import com.atguigu.gulimall.search.service.SkuSaveToEsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("product/search")
public class SkuSaveToEsController {
    @Autowired
    private SkuSaveToEsService skuSaveToEsService;
    @PostMapping("save")
    public R productUp(@RequestBody List<SkuEsModel> skuEsModels){
            Boolean b= skuSaveToEsService.productUpToEs(skuEsModels);
            if (!b){
                return R.ok();
            }else {
                return R.error();
            }
    }
}
